/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package index;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;

/**
 *
 * @author Danang
 */
public class Reader {
    protected RandomAccessFile fileReader;
    
    public Reader(String path) throws FileNotFoundException {
        fileReader = new RandomAccessFile(path, "r");
    }
    
    public String readBytes(long pos, int byteNum) throws IOException {
        fileReader.seek(pos);
        byte[] b = new byte[byteNum];
        fileReader.read(b);
        return new String(b);
    }
    
    public String readLineAtPosition(long pos) throws IOException {
        fileReader.seek(pos);
        return fileReader.readLine();
    }
        
    public void  close() throws IOException {
        fileReader.close();
    }
    
}
